package com.xiaxiang.xiawan.share;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;

import com.third.login.ThirdLoginFactory;
import com.third.login.ThirdLoginPlatform;
import com.third.share.ShareData;
import com.third.share.ThirdShareBase;
import com.third.share.ThirdShareListener;

/**
 * Created by Administrator on 2017-10-19.
 */

public class ShareTest implements ThirdShareListener{
    private Activity mAct;
    private ThirdShareBase mWeiXinShare;
    public final static int TEXT = 1001;
    public final static int IMAGELOCAL = 1002;
    public final static int IMAGEURL =1003;
    public final static int TEXTANDIMAGE =1004;
    public final static int  MUSIC00= 1005;
    public final static int  MUSIC11= 1006;
    public final static int  MUSIC10= 1007;
    public final static int  MUSIC01= 1008;
    public final static int  VIDEO00= 1009;
    public final static int  VIDEO11= 1010;
    public final static int  VIDEO10= 1011;
    public final static int  VIDEO01= 1012;
    public final static int  WEB00= 1013;
    public final static int  WEB11= 1014;
    public final static int  WEB10= 1015;
    public final static int  WEB01= 1016;
    public final static int  EMOJI= 1017;
    public final static int  FILE= 1018;
    public final static int  MINAPP= 1019;
    private Handler mHandler;
    public ShareTest(Activity act){
        mAct = act;
        mWeiXinShare = ThirdLoginFactory.getThirdShare("com.third.share.umeng.tencent.UWeiXinShare",act);
        mWeiXinShare.setThirdShareListener(this);
        setHandler();
    }

    private void setHandler(){
        mHandler = new Handler(Looper.getMainLooper()){
            public void handleMessage(Message msg){
                super.handleMessage(msg);
                int style = msg.what;
                ShareData shareData = new ShareData(ThirdLoginPlatform.WEIXIN);
                shareData.mShareStyle = style;
                mWeiXinShare.thirdShare(shareData);
            }
        };
    }
    public void startShare(int style){
        mHandler.sendEmptyMessage(TEXT);
    }
    @Override
    public void onCancel(ThirdLoginPlatform platform) {
        Log.e("share","share cancel platform is "+platform);
    }

    @Override
    public void onError(ThirdLoginPlatform platform, Throwable arg1) {
        Log.e("share","share onError platform is "+platform);
    }

    @Override
    public void onResult(ThirdLoginPlatform platform) {
        Log.e("share","share onResult platform is "+platform);
    }

    @Override
    public void onStart(ThirdLoginPlatform platform) {
        Log.e("share","share onStart platform is "+platform);
    }

    public  void onResume(){
        mWeiXinShare.onResume();
    }
    public  void onActivityResult(int requestCode, int resultCode, Intent data){
        mWeiXinShare.onActivityResult(requestCode,resultCode,data);
    }
    public  void onDestroy(){
        mWeiXinShare.onDestroy();
    }
    public  void cancelShare(){

    }
}
